package com.sairobo.admin.modules.srblive.manager.impl;

import java.util.Arrays;
import java.util.List;

import java.util.HashMap;
import java.util.Map;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Component;

import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.constant.QueryConts;
import com.sairobo.base.common.entity.Query;
import com.sairobo.admin.modules.srblive.dao.SrbliveLiveroomtypeMapper;
import com.sairobo.admin.modules.srblive.entity.SrbliveLiveroomtype;
import com.sairobo.admin.modules.srblive.manager.SrbliveLiveroomtypeManager;

/**
 * 直播间类型
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月11日 下午8:04:39
 */
@Component("srbliveLiveroomtypeManager")
public class SrbliveLiveroomtypeManagerImpl extends ServiceImpl<SrbliveLiveroomtypeMapper,SrbliveLiveroomtype> implements SrbliveLiveroomtypeManager {
    
	@Override
	public List<SrbliveLiveroomtype> listSrbliveLiveroomtype(Page<SrbliveLiveroomtype> page, Query search) {
        EntityWrapper<SrbliveLiveroomtype> ew=new EntityWrapper<SrbliveLiveroomtype>();
        //搜索条件
        Map map = (HashMap)search.get(QueryConts.SEARCH_KEYWORD);
        ew.like(true,"name",(String) map.get("key"));
        //ew.eq(false,"XXX",(String) map.get("key"));
        ew.orderBy("id",false);
        //ew.orderBy("create_time",false);
        return baseMapper.selectPage(page,ew);
	}

	@Override
	public int saveSrbliveLiveroomtype(SrbliveLiveroomtype srbliveLiveroomtype) {
        return baseMapper.insert(srbliveLiveroomtype);
	}

	@Override
	public SrbliveLiveroomtype getSrbliveLiveroomtypeById(Long id) {
        SrbliveLiveroomtype test = baseMapper.selectById(id);
        return test;
	}

	@Override
	public int updateSrbliveLiveroomtype(SrbliveLiveroomtype srbliveLiveroomtype) {
        return baseMapper.updateById(srbliveLiveroomtype);
	}

	@Override
	public int batchRemove(Long[] id) {
        int count = baseMapper.deleteBatchIds(Arrays.asList(id));
        return count;
	}
	
}
